<html th:fragment="header" xmlns:th="http://www.thymeleaf.org">
<style>
    #atama {
        height: 200px;
        background: #069;
        padding-top: 20px;
        border-bottom: 3px #555 solid; }
    #atama a {
        color: #fff; }
    #atama #title {
        width: 100px;
        margin: 0 auto;
        font-size: 28px;
        text-align: center;
        margin-bottom: 20px;
        border-left: 2px #fff solid;
        border-right: 2px #fff solid; }
    #atama #title:hover {
        background: #fff; }
    #atama #title a:hover {
        color: #069;
        text-decoration: none; }
    #atama #subtitle {
        width: 200px;
        height: 30px;
        line-height: 30px;
        margin: 0 auto;
        background: #fff;
        color: #069;
        text-align: center; }
    #atama nav {
        height: 30px;
        margin-top: 60px;
        text-align: center; }
    #atama nav li {
        list-style: none; }
    #atama nav a {
        display: inline-block;
        margin: 0 10px 0 10px; }
    #atama nav .tag-list-item {
        display: inline-block; }
</style>
<div id="atama">
    <div id="title"><a href="/">青池</a></div>
    <div id="subtitle"><span>受尽晚风吹，夏日不起早</span></div>
    <nav>
        <ul class="tag-list" id="container">
            <li id="loading">分类获取中...</li>
        </ul>
    </nav>
</div>
<script>
    var ul = document.querySelector('#container');
    var loading = document.querySelector('#loading');

    fetch('/category').then(function(res) {
      return res.json();
    }).then(function(data) {
      ul.removeChild(loading);

      data.forEach(function(item) {
        var li = document.createElement('li');
        li.setAttribute('class', 'tag-list-item');

        var a = document.createElement('a');
        a.setAttribute('class', 'tag-list-link');
        a.setAttribute('href', '/list?cat=' + item.id);
        a.text = item.name;

        li.appendChild(a);
        ul.appendChild(li);
      });
    })
</script>
</html>
